package com.googlecode.agscrum.model.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Version;

@Entity
@SequenceGenerator(name = "seq_roleresourceaction", sequenceName = "seq_roleresourceaction")
public class RoleResourceAction {
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_roleresourceaction")
	@Column(name = "id_role_action")
	private Long id;
	@Version
	private Integer version;
	@ManyToOne
	@JoinColumn(name = "id_resource")
	private Resource resource;
	@ManyToOne
	@JoinColumn(name = "id_role")
	private Role role;
	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "ROLE_RES_ACTION", joinColumns = @JoinColumn(name = "id_role_action", referencedColumnName = "id_role_action"), inverseJoinColumns = @JoinColumn(name = "id_action", referencedColumnName = "id_action"))
	private List<Action> actions;
}
